import request from '../index'

/**
 * 获取文章评论
 * @param articleId {string | number}
 * @param offset {string | number}
 * @param limit {string | number}
 * @returns {Promise}
 */
export function getArticleDiscussList(articleId, offset, limit) {
  return request({
    url: '/discuss',
    params: {
      articleId,
      offset,
      limit
    }
  })
}

/**
 * 文章评论点赞/取消点赞
 * @param discussId {string | number}
 * @returns {Promise}
 */
export function getDiscussSupport(discussId) {
  return request({
    url: `/discuss/${discussId}/support`
  })
}

/**
 * 创建一条评论
 * @param articleId {string | number}
 * @param content {string}
 * @returns {Promise}
 */
export function postDiscussItem(articleId, content) {
  return request({
    url: '/discuss',
    method: 'POST',
    data: {
      content,
      articleId
    }
  })
}

/**
 * 删除一条评论
 * @param discussId {string | number}
 * @returns {Promise}
 */
export function deleteDiscussItem(discussId) {
  return request({
    url: `/discuss/${discussId}`,
    method: 'DELETE'
  })
}

/**
 * 回复一条评论
 * @param articleId {string | number}
 * @param discussId {string | number}
 * @param content {string}
 */

export function postReplyDiscuss(articleId, discussId, content) {
  return request({
    url: '/discuss/reply',
    method: 'POST',
    data: {
      articleId,
      discussId,
      content
    }
  })
}
